package com.example.starseas_phone.Adapters;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.example.starseas_phone.Entity.Evaluation;
import com.example.starseas_phone.R;

import java.util.List;

public class Stu_EvaluationlistviewAdapter extends ArrayAdapter<Evaluation> {
    private int id;
    private Context mcontext;

    public Stu_EvaluationlistviewAdapter(@NonNull Context context, int resource, @NonNull List<Evaluation> objects) {
        super(context, resource, objects);
        id = resource;
        mcontext = context;
    }

    @NonNull
    @Override
    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
        Evaluation evaluation = getItem(position);
        View view = LayoutInflater.from(parent.getContext()).inflate(id,parent,false);
        TextView stu_evaluation_listview_CourseName = (TextView) view.findViewById(R.id.stu_evaluation_listview_CourseName);
        TextView stu_evaluation_listview_WorkerName = (TextView) view.findViewById(R.id.stu_evaluation_listview_WorkerName);
        TextView stu_evaluation_listview_WorkerEvaluationSum = (TextView) view.findViewById(R.id.stu_evaluation_listview_WorkerEvaluationSum);
        TextView stu_evaluation_listview_EvaluationOfTime = (TextView) view.findViewById(R.id.stu_evaluation_listview_EvaluationOfTime);

        stu_evaluation_listview_CourseName.setText(evaluation.getCourseName());
        stu_evaluation_listview_WorkerName.setText(evaluation.getWorkerName());
        int sum = Integer.parseInt(evaluation.getWorkerEvaluationOption1())+Integer.parseInt(evaluation.getWorkerEvaluationOption2())+Integer.parseInt(evaluation.getWorkerEvaluationOption3())+Integer.parseInt(evaluation.getWorkerEvaluationOption4())+Integer.parseInt(evaluation.getWorkerEvaluationOption5());
        stu_evaluation_listview_WorkerEvaluationSum.setText(sum+"");
        stu_evaluation_listview_EvaluationOfTime.setText(evaluation.getEvaluationOfTime());

        return view;
    }

}
